<%@ Page Title="Pay_Amount Item" Language="C#" AutoEventWireup="true" CodeBehind="Pay_AmountItem.aspx.cs" Inherits="Youz.CreditRepay.Manage.Pay_AmountItem" %>

<script>
    //loadCSS("UIResources/Scripts/jquery.validate/valid.css");

    var requireJS = [
        //"assets/js/jquery.form.js"
    ];
    loadJS(requireJS);
</script>
<div class="row">
    <div class="col-lg-12">
        <div class="panel panel-default">
            <div class="panel-heading">
                <h2><i class="fa fa-edit"></i><%: R(LanguageModule.Pay_Amount, "Pay_Amount", "Pay_Amount") %></h2>
            </div>
            <div class="panel-body">
                <form id="frm" class="form-horizontal" method="post" enctype="multipart/form-data" action="Pay/Handlers/Pay_AmountHandler.ashx?type=save">
                    <input id="ID" name="ID" type="hidden" />
                    <div class="form-group">
                        <label class="control-label" for="PayType"><%: R(LanguageModule.Pay_Amount, "PayType", "付款类型") %></label>
                        <div class="controls">
                            <input type="hidden" id="PayType" name="PayType" value="<%: WebHelper.Get<int>("t") %>" />
                            <input type="text" value="<%: WebHelper.Get<int>("t") == 0 ? "支付宝" : "微信" %>" readonly="readonly" maxlength="4" class="form-control required" /></div>
                    </div>
                    <div class="form-group">
                        <label class="control-label" for="Amount"><%: R(LanguageModule.Pay_Amount, "Amount", "金额") %></label>
                        <div class="controls">
                            <input type="number" id="Amount" name="Amount" min="0.01" maxlength="9" class="form-control required" /></div>
                    </div>
                    <div class="form-group">
                        <label class="control-label" for="Remark"><%: R(LanguageModule.Pay_Amount, "Remark", "说明") %></label>
                        <div class="controls">
                            <textarea id="Remark" name="Remark" rows="3" maxlength="1000" class="form-control"></textarea></div>
                    </div>
                    <div class="form-group">
                        <label class="control-label" for="IsEnabled"><%: R(LanguageModule.Pay_Amount, "IsEnabled", "是否启用") %></label>
                        <div class="controls">
                            <label class="switch switch-info">
                                <input type="checkbox" id="IsEnabled" name="IsEnabled" class="switch-input" /><span class="switch-label" data-on="On" data-off="Off"></span><span class="switch-handle"></span></label></div>
                    </div>
                    <div class="alert alert-danger" style="display: none;">
                        <button type="button" class="close" data-dismiss="alert">×</button><strong>Oh snap!</strong><span class="content"></span></div>
                    <div class="form-actions">
                        <button class="btn btn-success" type="submit" id="btnSubmit"><%: R(LanguageModule.M_Common, "btnSubmit", "保存修改") %></button>
                        <button class="btn btn-default" type="button" id="btnCancel"><%: R(LanguageModule.M_Common, "btnCancel", "取消") %></button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">

    var flag = false;

    function validate() {
        return $("#frm").valid();
    };

    function get() {
        $.post("Pay/Handlers/Pay_AmountHandler.ashx?type=get", { ID: "<%= WebHelper.Get("ID") %>" }, function (data) {
            $('#frm').fill(data);
        }, 'json');
    }

    $(function () {
        $("#frm").validate({
            errorElement: "span"
        });

        get();

        $("#frm").ajaxForm({
            dataType: 'json',
            beforeSubmit: function (arr, $form, options) {
                if (flag) {
                    return false;
                }
                else {
                    flag = true;
                    return true;
                }
            },
            success: function (data) {
                if (data.isSuccess) {
                    loadPage("Pay/Pay_AmountList.aspx?t=<%: WebHelper.Get<int>("t")%>");
                }
                else {
                    $(".alert > .content").html(data.message);
                    $(".alert").show();
                }
                flag = false;
            }
        });

        $("#btnCancel").click(function () {
            loadPage("Pay/Pay_AmountList.aspx?t=<%: WebHelper.Get<int>("t")%>");
        });
    });

</script>
